﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Windows.Media.Imaging;
using CAION2.Models;

namespace CAION2.Classes
{
    public class Idian
    {
        private string translate;
        private BitmapSource icon;
        private string chance;
        private string name;
        private string quality;
        private KeyValuePair<string, Single> random1;
        private KeyValuePair<string, Single> random2;
        private KeyValuePair<string, Single> random3;
        private KeyValuePair<string, Single> random4;
        private KeyValuePair<string, Single> random5;
        private KeyValuePair<string, Single> random6;
        private KeyValuePair<string, Single> random7;
        private KeyValuePair<string, Single> random8;   
        
        public string Translate
        {
            get { return translate; }
            set
            {
                if (Equals(translate, value)) return;
                translate = value;
            }
        }

        public string Name
        {
            get { return name; }
            private set
            {
                if (Equals(name, value)) return;
                name = value;
            }
        }

        public string Quality
        {
            get { return quality; }
            set
            {
                if (Equals(quality, value)) return;
                quality = value;
            }
        }

        public BitmapSource Icon
        {
            get { return icon; }
            set
            {
                if (Equals(icon, value)) return;
                icon = value;
            }
        }

        public string Chance
        {
            get { return chance; }
            set
            {
                if (Equals(chance, value)) return;
                chance = value;
            }
        }

        public KeyValuePair<string, Single> Random1
        {
            get { return random1; }
            set
            {
                if (Equals(random1, value)) return;
                random1 = value;
            }
        }

        public KeyValuePair<string, Single> Random2
        {
            get { return random2; }
            set
            {
                if (Equals(random2, value)) return;
                random2 = value;
            }
        }

        public KeyValuePair<string, Single> Random3
        {
            get { return random3; }
            set
            {
                if (Equals(random3, value)) return;
                random3 = value;
            }
        }

        public KeyValuePair<string, Single> Random4
        {
            get { return random4; }
            set
            {
                if (Equals(random4, value)) return;
                random4 = value;
            }
        }

        public KeyValuePair<string, Single> Random5
        {
            get { return random5; }
            set
            {
                if (Equals(random5, value)) return;
                random5 = value;
            }
        }

        public KeyValuePair<string, Single> Random6
        {
            get { return random6; }
            set
            {
                if (Equals(random6, value)) return;
                random6 = value;
            }
        }

        public KeyValuePair<string, Single> Random7
        {
            get { return random7; }
            set
            {
                if (Equals(random7, value)) return;
                random7 = value;
            }
        }

        public KeyValuePair<string, Single> Random8
        {
            get { return random8; }
            set
            {
                if (Equals(random8, value)) return;
                random8 = value;
            }
        }
        
        public Idian()
        {
            
        }

        public Idian(DataRow row, bool isCut = false)
        {
            CreateIdian(row, isCut);
        }

        public Idian(string idianName, bool isCut = false)
        {
            CreateIdian(DataModel.GetRowAtName("Polish", idianName), isCut);
        }

        private void CreateIdian(DataRow row, bool isCut = false)
        {
            Icon = new BitmapImage(new Uri(DataModel.IconsDirectory + row["icon_name"] + ".png", UriKind.RelativeOrAbsolute));
            Translate = row["translate" + DataModel.EngFix].ToString();
            Name = row["name"].ToString();
            Quality = row["quality"].ToString();

            if (isCut) return;

            Chance = (Convert.ToInt16(row["prob"].ToString()) / 100) + "%";
            Random1 = CardStat.GetStat(row["random_attr1"].ToString());
            Random2 = CardStat.GetStat(row["random_attr2"].ToString());
            Random3 = CardStat.GetStat(row["random_attr3"].ToString());
            Random4 = CardStat.GetStat(row["random_attr4"].ToString());
            Random5 = CardStat.GetStat(row["random_attr5"].ToString());
            Random6 = CardStat.GetStat(row["random_attr6"].ToString());
            Random7 = CardStat.GetStat(row["random_attr7"].ToString());
            Random8 = CardStat.GetStat(row["random_attr8"].ToString());
        }
        
    }
}
